package hiho.week._69;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		int[] dices = new int[n];
		for (int i = 0; i < n; i++)
			dices[i] = in.nextInt();
		int i = 0;
		int j = m + 1;
		while (i < j - 1) {
			int mid = (i + j) / 2;
			if (check(dices, n, mid))
				j = mid;
			else
				i = mid;
		}
		System.out.println(j);
	}
	
	private static boolean check(int[] dices, int n, int t) {
		int now = 0;
		int win = 0;
		for (int i = 0; i < n; i++) {
			now += t;
			if (now > dices[i]) {
				win++;
				if (n - win < win)
					return true;
				now -= dices[i];
			} else
				now = 0;
		}
		return false;
	}

}
